/**
 * @param {number[]} candidates
 * @param {number} target
 * @return {number[][]}
 */
var combinationSum = function (candidates, target) {
	const res = []
	const dfs = (start, comb, sum) => {
		if (sum >= target) {
			if (sum === target) {
				res.push(comb.slice())
			}
			return
		}
		for (let i = start; i < candidates.length; i++) {
			const n = candidates[i]
			comb.push(n)
			dfs(i, comb, sum + n) // 基于i，传下去，就不会选中i左边的数
			comb.pop()
		}
	}
	dfs(0, [], 0)
	return res
}
const res = combinationSum([2, 3, 6, 7], 7)
console.log(res)
